package xin.marcher.module.common.enums.seller;

import java.util.HashMap;
import java.util.Map;

/**
 * 存储条件
 */
public enum StoreLabelEnum {

    /**
     * 常温
     */
    HOMOIOTHERMAL(1, "常温"),
    /**
     * 冷藏
     */
    COLD_STORAGE(2, "冷藏"),
    /**
     * 冷冻
     */
    FROZEN(3, "冷冻"),
    /**
     * 水产
     */
    AQUATIC(4, "水产");

    private Integer code;

    private String value;

    StoreLabelEnum(Integer code, String value) {
        this.code = code;
        this.value = value;
    }

    public Integer getCode() {
        return code;
    }

    public String getValue() {
        return value;
    }

    public static Map<Integer, String> toMap() {
        Map<Integer, String> map = new HashMap<>(16);
        for (StoreLabelEnum element : StoreLabelEnum.values()) {
            map.put(element.getCode(), element.getValue());
        }
        return map;
    }

    public static StoreLabelEnum getByCode(Integer code) {
        if (code == null) {
            return null;
        }
        for (StoreLabelEnum element : StoreLabelEnum.values()) {
            if (code.equals(element.getCode())) {
                return element;
            }
        }
        return null;
    }
}
